package com.headwind.logistics.prople.controller;

import com.headwind.logistics.common.pojo.Address;
import com.headwind.logistics.common.util.LayuiUtil;
import com.headwind.logistics.prople.dto.CustomerAddressDTO;
import com.headwind.logistics.prople.service.inter.CustomerAddressServiceInter;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author Gu1028
 * @Date 2020/7/25 10:06
 * @Version 1.0
 * @DESCRIPTION 顾客收货地址控制器层
 */
@Controller
public class CustomerAddressController {

    //部门业务逻辑层接口
    @Resource
    private CustomerAddressServiceInter customerAddressServiceInter;

    /**
     * 获取分页部门信息
     * @param page
     * @param limit
     * @return
     */
    @GetMapping("/admin/prople/selectAllCustomerAddress")
    @ResponseBody
    public LayuiUtil selectAllCustomerAddress(Integer page, Integer limit){
        //获取分页部门
        List<CustomerAddressDTO> customerAddressDTOS = customerAddressServiceInter.selectAllCustomerAddress(page, limit);

        return LayuiUtil.data(customerAddressServiceInter.selectAllCustomerAddress(page,limit).size(),customerAddressDTOS);
    }

    /**
     * 根据姓名、性别、手机号、用户状态 搜索顾客
     * @param customerAddressDTO
     */
    @GetMapping("/admin/prople/queryCustomerAddressByNameOrPhone")
    @ResponseBody
    public LayuiUtil queryCustomerAddressByNameOrPhone(CustomerAddressDTO customerAddressDTO, Integer page, Integer limit) {
        //获取分页部门
        List<CustomerAddressDTO> customerAddressDTOS = customerAddressServiceInter.queryCustomerAddressByNameOrPhone(customerAddressDTO,page, limit);



        return LayuiUtil.data(customerAddressServiceInter.queryCustomerAddressByNameOrPhone(customerAddressDTO,page,limit).size(),customerAddressDTOS);
    }


    @GetMapping("/admin/prople/selectAllCustomerAddressByUserId/{userId}")
    @ResponseBody
    public LayuiUtil selectAllCustomerAddressByUserId(@PathVariable("userId") String userID, Integer page, Integer limit){
        System.out.println("进来了"+userID);
        //获取分页部门
        List<CustomerAddressDTO> customerAddressDTOS = customerAddressServiceInter.selectAllCustomerAddressByUserId(page, limit,userID);

        return LayuiUtil.data(customerAddressServiceInter.selectAllCustomerAddressByUserId(0, 0,userID).size(),customerAddressDTOS);
    }
}
